package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.onlyforchecker;
import com.ruoyi.system.service.IonlyforcheckerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 养护抽检Controller
 * 
 * @author xjj
 * @date 2022-05-17
 */
@RestController
@RequestMapping("/system/onlyforchecker")
public class onlyforcheckerController extends BaseController
{
    @Autowired
    private IonlyforcheckerService onlyforcheckerService;

    /**
     * 查询养护抽检列表
     */
    @PreAuthorize("@ss.hasPermi('system:onlyforchecker:list')")
    @GetMapping("/list")
    public TableDataInfo list(onlyforchecker onlyforchecker)
    {
        startPage();
        List<onlyforchecker> list = onlyforcheckerService.selectonlyforcheckerList(onlyforchecker);
        return getDataTable(list);
    }

    /**
     * 导出养护抽检列表
     */
    @PreAuthorize("@ss.hasPermi('system:onlyforchecker:export')")
    @Log(title = "养护抽检", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, onlyforchecker onlyforchecker)
    {
        List<onlyforchecker> list = onlyforcheckerService.selectonlyforcheckerList(onlyforchecker);
        ExcelUtil<onlyforchecker> util = new ExcelUtil<onlyforchecker>(onlyforchecker.class);
        util.exportExcel(response, list, "养护抽检数据");
    }

    /**
     * 获取养护抽检详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:onlyforchecker:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return AjaxResult.success(onlyforcheckerService.selectonlyforcheckerByRecordId(recordId));
    }

    /**
     * 新增养护抽检
     */
    @PreAuthorize("@ss.hasPermi('system:onlyforchecker:add')")
    @Log(title = "养护抽检", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody onlyforchecker onlyforchecker)
    {
        return toAjax(onlyforcheckerService.insertonlyforchecker(onlyforchecker));
    }

    /**
     * 修改养护抽检
     */
    @PreAuthorize("@ss.hasPermi('system:onlyforchecker:edit')")
    @Log(title = "养护抽检", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody onlyforchecker onlyforchecker)
    {
        return toAjax(onlyforcheckerService.updateonlyforchecker(onlyforchecker));
    }

    /**
     * 删除养护抽检
     */
    @PreAuthorize("@ss.hasPermi('system:onlyforchecker:remove')")
    @Log(title = "养护抽检", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(onlyforcheckerService.deleteonlyforcheckerByRecordIds(recordIds));
    }
}
